Skip to main content

CMD - Client to Server

The client calls the server function using Command(CMD). In general, there are very few cases where the client calls the server function.

โ€‹

Similarly, complete the function and register

function WeaponFlyObj:NetworkInject()    self.host.interact.networkIB.networkIBState:InjectFunc("CmdToShoot", self.CmdToShoot)    --inject other functionend
function WeaponFlyObj:CmdToShoot()    --Server shootend

The client uses the interface CommandFunc (Please read NetworkIBStateX for more interfaces) in networkIBState to call function (CmdToShoot) in the server.

CommandFunc(funtionName)

  • functionName: Name of the function to call on the server
    function WeaponFlyObj:ClientToShoot()    self.host.interact.networkIB.networkIBState:CommandFunc("CmdToShoot", null, null, null, null)end